package com.gxuwz.zlc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gxuwz.zlc.entity.Lab;
import com.gxuwz.zlc.mapper.LabMapper;
import com.gxuwz.zlc.service.LabService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LabServiceImpl implements LabService {

    @Autowired
    private LabMapper labMapper;

    @Override
    public List<Lab> findLab() {
        return labMapper.selectList(null);
    }

    @Override
    public Lab findLabById(String labId) {
        return labMapper.selectById(labId);
    }

    @Override
    public void addLab(Lab lab) {
        labMapper.insert(lab);
    }

    @Override
    public void updateLab(Lab lab) {
        labMapper.updateById(lab);
    }

    @Override
    public void deleteLab(String labId) {
        labMapper.deleteById(labId);
    }

    /**
     * 根据实验室名称查询
     * @param labName
     * @return
     */
    @Override
    public List<Lab> findLabByLabName(String labName) {
        QueryWrapper<Lab> wrapper = new QueryWrapper<>();
        wrapper.eq("lab_name",labName);
        return labMapper.selectList(wrapper);
    }
}
